import * as consts from './constact'

// 专门为count组件生成action对象

//同步action就是值action的值为Object类型的一般对象
export const createIncrementAction = data => ({ type: consts.INCREMENT, data })
export const createDecrementAction = data => ({ type: consts.DECREMENT, data })

//异步action就是值action的值为函数,异步action中一般都会调用同步action，异步action不是必须用的
export const createDecrementAsyncAction = (data, time) => {
    return (dispatch) => {
        setTimeout(() => {
            dispatch(createIncrementAction(data))
        }, time);
    }
}